﻿using HCLSMod.ShowErrorInfo;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace HCLSMod
{
    public partial class FErrorListManager : Form
    {
        ZLErrorRecord fErrorRecNode = null;
        public FErrorListManager(ZLErrorRecord fErrorEvents)
        {
            InitializeComponent();
            fErrorRecNode = fErrorEvents;
            if (fErrorRecNode != null)
            {
                foreach (Exception ex in fErrorEvents.ErrorList)
                {
                    FErrorEvetInfo fErrorInfo = new FErrorEvetInfo(ex);
                    fErrorInfo.SetParent(panelErrorWorkSpace);
                }
                labelErrorCount.Text = string.Format("ErrorCount:{0}", fErrorEvents.ErrorCount());
            }
        }
        public FErrorListManager(string[] fErrorInfo)
        {
            InitializeComponent();
            if (fErrorInfo != null)
            {
                foreach (string ex in fErrorInfo)
                {
                    FErrorEvetInfo fErrorInfoStr = new FErrorEvetInfo(ex);
                    fErrorInfoStr.SetParent(panelErrorWorkSpace);
                }
                labelErrorCount.Text = string.Format("ErrorCount:{0}", fErrorInfo.Length.ToString());
            }
        }
        public static void ShowErrorList(ZLErrorRecord fErrorEvents)
        {
            FErrorListManager fErrManager = new FErrorListManager(fErrorEvents);
            fErrManager.ShowDialog();            
        }

        public static void ShowErrorList(string[] fErrorInfo)
        {
            FErrorListManager fErrManager = new FErrorListManager(fErrorInfo);
            fErrManager.ShowDialog();
        }
    }
}
